﻿/* 
 * Enterprise Library Extensions - DI + ORM.
 * Copyright (C) 2006
 *
 * GNU General Public License
 *
 * This program is free software; you can redistribute 
 * it and/or modify it under the terms of the GNU General Public License 
 * as published by the Free Software Foundation; either version 2 of the 
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful, but 
 * WITHOUT ANY WARRANTY; without even the implied warranty of 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
 * See the GNU General Public License for more details.
 */
#region Using directives

using System;
using System.Text;
using System.Collections;

#endregion

namespace ELE.EnterpriseLibrary.Naming.Configuration
{
  /// <summary>
  /// 
  /// </summary>
  public class GenericCollectionInitializer
  {
    /// <summary>
    /// Defines a list
    /// </summary>
    public const int TYPE_LIST = 0;
    /// <summary>
    /// Defines a dictionary
    /// </summary>
    public const int TYPE_DICTIONARY = 1;
    /// <summary>
    /// Represents the generic list type name <see cref="System.Collections.Generic.List&lt;T&gt;"/>
    /// </summary>
    public const string GENERICTYPE_LIST = "System.Collections.Generic.List";
    /// <summary>
    /// Represents the generic type for <see cref="System.Collections.Generic.Dictionary&lt;T,T&gt;"/>
    /// </summary>
    public const string GENERICTYPE_DICTIONARY = "System.Collections.Generic.Dictionary";
    private string mName;
    private ArrayList mValues;
    private int mType = TYPE_LIST;
    private string mGenericKeyType = (typeof(string)).FullName;
    private string mGenericValueType = (typeof(string)).FullName;
    private string mGenericCollectionType = GENERICTYPE_LIST;

    /// <summary>
    /// 
    /// </summary>
    public GenericCollectionInitializer()
    {
    }
    /// <summary>
    /// 
    /// </summary>
    public GenericCollectionInitializer(string name, int type)
    {
      mName = name;
      mType = type;
    }
    /// <summary>
    /// 
    /// </summary>
    /// <value></value>
    public string Name
    {
      get { return mName; }
      set { mName = value; }
    }
    /// <summary>
    /// 
    /// </summary>
    /// <value></value>
    public ArrayList Entries
    {
      get { return mValues; }
      set { mValues = value; }
    }
    /// <summary>
    /// 
    /// </summary>
    /// <value></value>
    public int Type
    {
      get { return mType; }
      set { mType = value; }
    }
    /// <summary>
    /// In the case of dictionaries, the type of th keys
    /// </summary>
    public string GenericKeyType
    {
      get { return mGenericKeyType; }
      set { mGenericKeyType = value; }
    }
    /// <summary>
    /// Type of the value of the items in the list or dictionary
    /// </summary>
    public string GenericValueType
    {
      get { return mGenericValueType; }
      set { mGenericValueType = value; }
    }
    /// <summary>
    /// Collection type
    /// </summary>
    public string GenericType
    {
      get { return mGenericCollectionType; }
      set { mGenericCollectionType = value; }
    }
    /// <summary>
    /// Adds an entry inititalization data for the generics collection.
    /// </summary>
    /// <param name="entry"></param>
    public void AddEntry(object entry)
    {
      if (mValues == null)
      {
        mValues = new ArrayList();
      }
      mValues.Add(entry);
    }
  }
}
